package com.kantboot.util.common;

import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Data
@ControllerAdvice
@Accessors(chain = true)
public class KantbootBaseException extends RuntimeException{

    private Integer state = 3000;
    private String message;

    @ExceptionHandler(value = KantbootBaseException.class)
    @ResponseBody
    public RestResult<String> kantbootBaseException(HttpServletRequest req, KantbootBaseException e){
        return new RestResult<String>().setState(e.getState()).setErrMsg(e.getMessage());
    }


}
